import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../../../resource/language/generated/l10n.dart';
import '../../interface/root_proxy_model.dart';
import '../relate_room_list/room_list_item_widget.dart';
import 'recommend_room_list_page_model.dart';

class RecommendRoomListPage extends StatefulWidget {
  /// 默认选中的index（默认为 0）0:热门 1：聊天交友 2：点唱 3：收藏
  int index;

  /// 标题，外部传入
  String title;

  /// 按钮标题
  String? btnTitle;

  RecommendRoomListPage({
    Key? key,
    required this.index,
    required this.title,
    String? btnTitle,
  }) : super(key: key) {
    this.btnTitle = btnTitle ?? T.current.recommend;
  }

  @override
  State<RecommendRoomListPage> createState() => _RecommendRoomListPageState();
}

class _RecommendRoomListPageState extends State<RecommendRoomListPage> {
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(
            create: (context) => RecommendRoomListPageModel(widget.index))
      ],
      child: Consumer<RecommendRoomListPageModel>(
        builder: (context, model, child) {
          return Container(
            height: 522,
            child: Column(
              children: [
                const SizedBox(
                  height: 20,
                ),
                Text(
                  widget.title,
                  style: const TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.w500,
                    color: Color(0xff333333),
                  ),
                ),
                const SizedBox(
                  height: 20,
                ),
                Text('DFListPullRefreshWidget'),
                // Expanded(
                //   child: DFListPullRefreshWidget(
                //     controller: model.refreshController,
                //     onLoading: model.loadMore,
                //     onRefresh: model.refreshData,
                //     canLoad: model.canLoadMore,
                //     canRefresh: true,
                //     content: ListView.builder(
                //       itemCount: model.itemList.length,
                //       itemBuilder: (context, index) {
                //         return RoomListItemWidget(
                //           channel: model.itemList[index],
                //           btnStr: widget.btnTitle!,
                //           btnOnPressed: () {
                //             model.onItemPressed(context, model.itemList[index]);
                //             Navigator.pop(context, true);
                //           },
                //           bgOnPressed: () {
                //             /// 当前用户跳转到目标房间
                //             model.jumpRoom(context, model.itemList[index]);
                //           },
                //         );
                //       },
                //     ),
                //   ),
                // ),
              ],
            ),
          );
        },
      ),
    );
  }
}
